<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="824.48">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 47.0px; text-indent: -20.0px; font: 12.0px Helvetica}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0026b4}
p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #001bb9}
p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #2c7014}
span.s1 {color: #0039da}
span.s2 {color: #000000}
span.s3 {color: #0026b4}
span.s4 {color: #9d1c12}
span.s5 {color: #3d6d1d}
span.s6 {color: #001bb9}
span.s7 {color: #2c7014}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><b>MdaPiano<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Piano synthesiser</b></p>
<p class="p2"><br></p>
<p class="p3"><b>MdaPiano.ar(freq, gate, ... )</b></p>
<p class="p2"><br></p>
<p class="p3">A piano synthesiser <i>(originally a VST plugin by </i><a href="http://mda.smartelectronix.com/"><span class="s1"><i>Paul Kellett</i></span></a><i>, ported to SC by Dan Stowell)</i>. This UGen is not polyphonic (but can be retriggered to play notes in sequence). Note: This UGen is stereo - it returns two channels, with a stereo "wideness" effect controlled by the <b>stereo</b> argument. It has lots of parameters:</p>
<p class="p2"><br></p>
<p class="p4"><b>freq</b> - Frequency of the note</p>
<p class="p4"><b>gate</b> - note-on occurs when gate goes from nonpositive to positive; note-off occurs when it goes from positive to nonpositive. Most of the other controls are only updated when a new note-on occurs.</p>
<p class="p4"><b>vel</b> - velocity (range is 0 to 127, default 100)</p>
<p class="p4"><b>decay</b> - The time for notes to decay after the initial strike (default 0.8)</p>
<p class="p4"><b>release</b> - The time for notes to decay after the key is released (default 0.8)</p>
<p class="p4"><b>hard</b> -<span class="Apple-converted-space"> </span></p>
<p class="p4"><b>velhard</b> -<span class="Apple-converted-space"> </span></p>
<p class="p4"><b>muffle</b> -<span class="Apple-converted-space"> </span></p>
<p class="p4"><b>velmuff</b> -<span class="Apple-converted-space"> </span></p>
<p class="p4"><b>velcurve</b> -<span class="Apple-converted-space"> </span></p>
<p class="p4"><b>stereo</b> - Width of the stereo effect (which makes low notes sound towards the left, high notes towards the right). 0 to 1.</p>
<p class="p4"><b>tune</b> - Overall tuning</p>
<p class="p4"><b>random</b> - Randomness in note tuning (default 0.1)</p>
<p class="p4"><b>stretch</b> - Stretches the tuning out (higher notes pushed higher)</p>
<p class="p4"><b>sustain</b> - If positive, act as if the piano's sustain pedal is pressed.</p>
<p class="p2"><br></p>
<p class="p2"><br></p>
<p class="p3"><b>Examples</b></p>
<p class="p5"><br></p>
<p class="p6">s.boot;</p>
<p class="p5"><br></p>
<p class="p7">// This simple example triggers one note per second, monophonically:</p>
<p class="p6">(</p>
<p class="p6">x = {</p>
<p class="p8"><span class="s2"><span class="Apple-tab-span">	</span></span>MdaPiano<span class="s2">.ar(</span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s3">LFNoise0</span>.kr(1).range(20, 60).round.midicps, <span class="s4">// random note</span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>stereo: 0.5,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>gate: <span class="s3">LFPulse</span>.kr(1),<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>vel: <span class="s3">LFPar</span>.kr(0.1).range(10, 100), <span class="s4">// varying velocity</span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>mul: 0.2</p>
<p class="p6"><span class="Apple-tab-span">	</span>)</p>
<p class="p6">}.play</p>
<p class="p6">)</p>
<p class="p6">x.free;</p>
<p class="p5"><br></p>
<p class="p5"><br></p>
<p class="p7">// Now let's define a piano synthdef:</p>
<p class="p6">(</p>
<p class="p8">SynthDef<span class="s2">(</span><span class="s5">\help_mdapiano</span><span class="s2">, { </span>|out=0, freq=440, gate=1|</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s3">var</span> son = <span class="s3">MdaPiano</span>.ar(freq, gate, release: 0.9, stereo: 0.3, sustain: 0);</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s3">DetectSilence</span>.ar(son, 0.01, doneAction:2);</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s3">Out</span>.ar(out, son * 0.1);</p>
<p class="p6">}).memStore;</p>
<p class="p6">)</p>
<p class="p7">// Then we can use it in a pattern:</p>
<p class="p6">(</p>
<p class="p6"><span class="s6">TempoClock</span>.default.tempo = 1.2;</p>
<p class="p9">Ppar<span class="s2">([</span></p>
<p class="p9"><span class="s2"><span class="Apple-tab-span">	</span></span>Pbind<span class="s2">(</span></p>
<p class="p10"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>\instrument<span class="s2">, </span>\help_mdapiano<span class="s2">,</span></p>
<p class="p10"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>\degree<span class="s2">,<span class="Apple-converted-space"> </span></span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s6">Pseq</span>([<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>0, 7, -5, 7,<span class="Apple-converted-space">  </span>0, 5, -7, 5,<span class="Apple-converted-space">  </span>-2, 5, -7, 5,<span class="Apple-converted-space">  </span>-2,<span class="Apple-converted-space">  </span>3, -9,<span class="Apple-converted-space">  </span>3,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>0, 7, -5, 7,<span class="Apple-converted-space">  </span>0, 5, -7, 5,<span class="Apple-converted-space">  </span>-2, 5, -7, 5,<span class="Apple-converted-space">  </span>-2, -3, -4, -5 ], <span class="s6">inf</span>),</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\dur</span>, 0.5,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\octave</span>, 3,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\root</span>, 3,</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\vel</span>, <span class="s6">Prand</span>([<span class="s6">Pseq</span>([100, 30, 50, 10]), <span class="s6">Pseq</span>([100, 30, 10, 10, 5, 10, 20, 30])], <span class="s6">inf</span>),</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\legato</span>, 0.95</p>
<p class="p6"><span class="Apple-tab-span">	</span>),</p>
<p class="p9"><span class="s2"><span class="Apple-tab-span">	</span></span>Pbind<span class="s2">(</span></p>
<p class="p10"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>\instrument<span class="s2">, </span>\help_mdapiano<span class="s2">,</span></p>
<p class="p10"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>\degree<span class="s2">,<span class="Apple-converted-space"> </span></span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s6">Pseq</span>([ \, 0, -1, 0, 2, 0, \, \, \, 0, -2, \, \, -2, -4, \, \ ], <span class="s6">inf</span>),</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\dur</span>, 0.5,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\octave</span>, 6,<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\root</span>, 3,</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s7">\vel</span>, <span class="s6">Pwhite</span>(50, 100, <span class="s6">inf</span>)</p>
<p class="p6"><span class="Apple-tab-span">	</span>)</p>
<p class="p6">], <span class="s6">inf</span>).play</p>
<p class="p6">)</p>
<p class="p7">// Try changing the synthdef while this is running (e.g. activate sustain, tweak stereo)...</p>
</body>
</html>
